define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'warehose.product/index',
        finished_product_index_url: 'warehose.product/finished_product_index',  //成品库
        add_url: 'warehose.product/add',
        recovery_add_url: 'warehose.product/recovery_add',  //添加回收
        edit_url: 'warehose.product/edit',
        delete_url: 'warehose.product/delete',
        export_url: 'warehose.product/export',
        modify_url: 'warehose.product/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', minWidth: 80, title: '主键ID'},
                    {field: 'product_sku', minWidth: 80, title: '产品编号'},
                    {field: 'product_name', minWidth: 80, title: '产品名称'},
                    {field: 'productSpec.name', minWidth: 80, title: '规格'},
                    {field: 'warehouse_add_time', minWidth: 80, title: '入库时间'},
                    {field: 'product_status', minWidth: 80, title: '产品状态'},
                    {field: 'product_code_image', minWidth: 80, title: '二维码' ,search: false},
                    // {field: 'product_create_time', minWidth: 80, title: '创建时间'},
                    {field: 'product_create_time', minWidth: 80, minWidth: 80, title: '创建时间', search: 'range'},

                    {field: 'product_update_time', minWidth: 80, title: '修改时间'},
                    {field: 'warehouse_id', minWidth: 80, title: '仓库ID'},
                    {width: 250, minWidth: 80, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        service_index: function () {   //维修库
            ea.table.render({
                init: init,
                // url: "service_index", //自定义请求url
                where: { // 在这里增加参数，这些参数将会作为查询字符串附加到 URL 上  
                    product_status: 2,  
                }, 
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', minWidth: 80, title: '主键ID'},
                    {field: 'product_sku', minWidth: 80, title: '产品编号'},
                    {field: 'product_name', minWidth: 80, title: '产品名称'},
                    {field: 'productSpec.name', minWidth: 80, title: '规格'},
                    {field: 'warehouse_add_time', minWidth: 80, title: '入库时间'},
                    {field: 'product_status', minWidth: 80, title: '产品状态'},
                    {field: 'product_code_image', minWidth: 80, title: '二维码' ,search: false},
                    // {field: 'product_create_time', minWidth: 80, title: '创建时间'},
                    {field: 'product_create_time', minWidth: 80, minWidth: 80, title: '创建时间', search: 'range'},

                    {field: 'product_update_time', minWidth: 80, title: '修改时间'},
                    {field: 'warehouse_id', minWidth: 80, title: '仓库ID'},
                    {width: 250, minWidth: 80, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        waste_index: function () {   //废弃库
            ea.table.render({
                init: init,
                // url: "waste_index", //自定义请求url
                where: { // 在这里增加参数，这些参数将会作为查询字符串附加到 URL 上  
                    product_status: 3,  
                }, 
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', minWidth: 80, title: '主键ID'},
                    {field: 'product_sku', minWidth: 80, title: '产品编号'},
                    {field: 'product_name', minWidth: 80, title: '产品名称'},
                    {field: 'productSpec.name', minWidth: 80, title: '规格'},
                    {field: 'warehouse_add_time', minWidth: 80, title: '入库时间'},
                    {field: 'product_status', minWidth: 80, title: '产品状态'},
                    {field: 'product_code_image', minWidth: 80, title: '二维码' ,search: false},
                    // {field: 'product_create_time', minWidth: 80, title: '创建时间'},
                    {field: 'product_create_time', minWidth: 80, minWidth: 80, title: '创建时间', search: 'range'},

                    {field: 'product_update_time', minWidth: 80, title: '修改时间'},
                    {field: 'warehouse_id', minWidth: 80, title: '仓库ID'},
                    {width: 250, minWidth: 80, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        finished_product_index: function () {   //成品库
            ea.table.render({
                init: init,
                // url: "finished_product_index", //自定义请求url
                where: { // 在这里增加参数，这些参数将会作为查询字符串附加到 URL 上  
                    product_status: 4,  
                }, 
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', minWidth: 80, title: '主键ID'},
                    {field: 'product_sku', minWidth: 80, title: '产品编号'},
                    {field: 'product_name', minWidth: 80, title: '产品名称'},
                    {field: 'productSpec.name', minWidth: 80, title: '规格'},
                    {field: 'warehouse_add_time', minWidth: 80, title: '入库时间'},
                    {field: 'product_status', minWidth: 80, title: '产品状态'},
                    {field: 'product_code_image', minWidth: 80, title: '二维码' ,search: false},
                    // {field: 'product_create_time', minWidth: 80, title: '创建时间'},
                    {field: 'product_create_time', minWidth: 80, minWidth: 80, title: '创建时间', search: 'range'},

                    {field: 'product_update_time', minWidth: 80, title: '修改时间'},
                    {field: 'warehouse_id', minWidth: 80, title: '仓库ID'},
                    {width: 250, minWidth: 80, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        recovery_add: function () { //添加回收
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});